﻿using System;
using System.Collections.Generic;
using System.Text;
using Evaluant.Uss.ObjectContext;

namespace BasicApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initilizes the configuration provider
            ObjectService os = new ObjectService("engines.config");

            // Creates a dedicated engine for the job
            ObjectContext oc = os.CreateObjectContext();

            // Deletes any already existing content and creates 
            // necessary resources
            oc.InitializeRepository();

            Customer c1 = new Customer();
            c1.Name = "Customer One";
            c1.Address = "1 Customer One avenue";

            Customer c2 = new Customer();
            c2.Name = "Customer Two";
            c2.Address = "1 Customer Two avenue";

            oc.BeginTransaction();
            oc.Serialize(c1);
            oc.Serialize(c2);
            oc.CommitTransaction();

            foreach(Customer c in oc.Load<Customer>(typeof(Customer)))
            {
                Console.WriteLine("Customer: {0} [{1}]", c.Name, c.Address);
            }

            Console.ReadLine();
        }
    }
}
